import 'package:family_expense/features/journey/models/region.dart';
import 'package:my_flutter_core/my_flutter_core.dart';

class RegionService {
  final String _url = '/region';
  final HttpRequestService _httpRequestService = HttpRequestService();

  /// Retrieves all [Region]s from backend service.
  Future<List<Region>> queryAll() async {
    // Gets the response of the http get request.
    final response = await _httpRequestService.get('$_url/query-all');

    // Parses the data from [Map<String, dynamic>] to [Region].
    return (response.payload as List<dynamic>)
        .map((p) => Region.fromJson(p))
        .toList();
  }
}
